<template>
  <top-bar :option="bar" :resizable="resizable" @ready="onReady"></top-bar>
</template>

<script>
import TopBar from 'vue-echarts-v3/src/lite.js'
import 'echarts/lib/chart/bar'
export default {
  props: ['setOption'],
  data () {
    return {
      resizable: true,
      bar: {
        title: {
          text: this.setOption.title,
          // subtext: '数据来自网络'
          textStyle: {
            fontFamily: 'PingFangSC-Regular',
            fontSize: 14,
            color: '#ffffff'
          },
          top: 20,
          left: 24
        },
        tooltip: {
          // trigger: 'axis',
          // axisPointer: {
          //   type: 'shadow'
          // }
        },
        // legend: {
        //   data: ['PV', 'UV']
        // },
        grid: {
          left: '8%',
          right: '4%',
          bottom: '0%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          show: false,
          boundaryGap: [0, 0.01]
        },
        yAxis: {
          type: 'category',
          data: ['北京', '上海', '武汉', '南京', '广州', '深圳', '西安', '成都', '重庆', '天津'],
          axisLabel: {
            fontFamily: 'PingFangSC-Regular',
            fontSize: 12,
            color: '#c7c7c7'
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          }
        },
        series: [
          {
            name: '2011年',
            type: 'bar',
            barWidth: '40%',
            data: [1118, 1290, 1366, 1487, 1549, 1622, 1762, 1822, 1990, 2001],
            itemStyle: {
              color: '#01bfff',
              barBorderRadius: [0, 8, 8, 0]
            },
            label: {
              normal: {
                show: true,
                position: 'right',
                textStyle: {
                  fontFamily: 'PingFangSC-Regular',
                  fontSize: 10,
                  color: '#c7c7c7'
                }
              }
            }
          }
          // {
          //   name: '2012年',
          //   type: 'bar',
          //   data: [19325, 23438, 31000, 121594, 134141, 681807]
          // }
        ]
      }
    }
  },
  methods: {
    onReady (instance) {
      console.log(instance)
    }
  },
  components: {
    TopBar
  }
}
</script>

<style lang="less" scoped>

</style>
